home *** CD-ROM | disk | FTP | other *** search
/ GameStar 1998 November (Bonus) / GAMESTAR11B.ISO / ENCYC99 / MM / T620273A.DCR / scripts_14_recordPuzzleInfo (puzzle utility).ls < prev    next >
Encoding:
Text File  |  1998-07-02  |  2.5 KB  |  80 lines

  1. on recordPuzzleInfo
  2.   set solvedField to new(#field)
  3.   set the name of solvedField to "solvedLocs"
  4.   put EMPTY into field "solvedLocs"
  5.   set typeField to new(#field)
  6.   set the name of typeField to "pieceTypes"
  7.   put EMPTY into field "pieceTypes"
  8.   set typeSolvedField to new(#field)
  9.   set the name of typeSolvedField to "typeSolvedList"
  10.   put EMPTY into field "typeSolvedList"
  11.   set fixedField to new(#field)
  12.   set the name of fixedField to "fixedPieces"
  13.   put EMPTY into field "fixedPieces"
  14.   set boardField to new(#field)
  15.   set the name of boardField to "boardRect"
  16.   set savedFrame to the frame
  17.   go(label("board"))
  18.   set boardRect to the rect of sprite 1
  19.   put boardRect into field "boardRect"
  20.   go(label("fixed"))
  21.   set fixedList to []
  22.   repeat with i = 48 down to 1
  23.     if the memberNum of sprite i <> 0 then
  24.       set thisRect to the rect of sprite i
  25.       set thisType to value("#" & word 1 of the name of the member of sprite i)
  26.       if intersect(thisRect, boardRect) = thisRect then
  27.         add(fixedList, [thisRect, thisType])
  28.       end if
  29.     end if
  30.   end repeat
  31.   put string(fixedList) into field "fixedPieces"
  32.   go(label("solved"))
  33.   set solvedList to [:]
  34.   set pieceTypes to [:]
  35.   set allSprites to []
  36.   repeat with i = 48 down to 1
  37.     if the memberNum of sprite i <> 0 then
  38.       set thisRect to the rect of sprite i
  39.       if intersect(thisRect, boardRect) = thisRect then
  40.         set addThisOne to 1
  41.         repeat with j in fixedList
  42.           if i = j then
  43.             set addThisOne to 0
  44.           end if
  45.         end repeat
  46.         if addThisOne then
  47.           addProp(solvedList, i, the loc of sprite i)
  48.           addProp(pieceTypes, i, value("#" & word 1 of the name of the member of sprite i))
  49.           add(allSprites, i)
  50.         end if
  51.       end if
  52.     end if
  53.   end repeat
  54.   put string(solvedList) into field "solvedLocs"
  55.   put string(pieceTypes) into field "pieceTypes"
  56.   set allTypes to []
  57.   set typeSymbols to []
  58.   set typeSolvedList to [:]
  59.   repeat with i in pieceTypes
  60.     set addThisType to 1
  61.     repeat with j in typeSymbols
  62.       if i = j then
  63.         set addThisType to 0
  64.       end if
  65.       exit repeat
  66.     end repeat
  67.     if addThisType then
  68.       add(allTypes, i)
  69.       addProp(typeSolvedList, i, [])
  70.     end if
  71.   end repeat
  72.   repeat with i in allSprites
  73.     set thisType to getProp(pieceTypes, i)
  74.     set thisList to getProp(typeSolvedList, thisType)
  75.     add(thisList, the loc of sprite i)
  76.   end repeat
  77.   put string(typeSolvedList) into field "typeSolvedList"
  78.   go(savedFrame)
  79. end
  80.